<html>
<head><meta charset="utf-8"><title>Fun bug · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html">Fun bug</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="194561323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194561323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194561323">(Apr 18 2020 at 20:02)</a>:</h4>
<p><a href="/user_uploads/4715/i_PT_7CCkzR1vkBGcINzMftC/image.png" title="image.png">image.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/i_PT_7CCkzR1vkBGcINzMftC/image.png" title="image.png"><img src="/user_uploads/4715/i_PT_7CCkzR1vkBGcINzMftC/image.png"></a></div><p>Here, we somehow fail to resolve <code>.enumerate()</code> (because impl trait syntax is involved), but <em>somehow</em> we manage to correctly resolve the <code>.map</code> call. I don't know how to explain this :D</p>



<a name="194562034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194562034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194562034">(Apr 18 2020 at 20:24)</a>:</h4>
<p>This is simple, Watson, <code>idx</code> type is deduced from usage.</p>



<a name="194562041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194562041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194562041">(Apr 18 2020 at 20:24)</a>:</h4>
<p>But how is the <code>.map</code> type deduced?</p>



<a name="194562049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194562049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194562049">(Apr 18 2020 at 20:25)</a>:</h4>
<p>From symbol index?</p>



<a name="194562050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194562050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194562050">(Apr 18 2020 at 20:25)</a>:</h4>
<p>Like, the inlay hint says <code>Map&lt;{unknown}, |...| -&gt; Ty&gt;</code></p>



<a name="194562054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194562054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194562054">(Apr 18 2020 at 20:25)</a>:</h4>
<p>Symbol index is not used during type inference. And I bet there are a bunch of <code>map</code>s</p>



<a name="194562164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194562164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194562164">(Apr 18 2020 at 20:28)</a>:</h4>
<p>Bruh, isn't symbol index kinda the last resort? Maybe you are lucky to get exactly Iterator.map...</p>



<a name="194567643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194567643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194567643">(Apr 18 2020 at 22:50)</a>:</h4>
<p>we find <code>Iterator::map</code> as a candidate, get an ambiguous result for the trait solving (because we don't have any self type / it's a variable), so we use it</p>



<a name="194567648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194567648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194567648">(Apr 18 2020 at 22:50)</a>:</h4>
<p>during method resolution, it's enough if the self type <em>may</em> implement the trait</p>



<a name="194716609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194716609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194716609">(Apr 20 2020 at 18:44)</a>:</h4>
<p>Fun fact: ra manages to infer the type where rustc bails...<br>
<a href="user_uploads/4715/AdZLMVC6zRfTluUmR7X8R5ky/image.png" title="user_uploads/4715/AdZLMVC6zRfTluUmR7X8R5ky/image.png">image.png</a></p>
<div class="message_inline_image"><a href="user_uploads/4715/AdZLMVC6zRfTluUmR7X8R5ky/image.png" title="image.png"><img src="user_uploads/4715/AdZLMVC6zRfTluUmR7X8R5ky/image.png"></a></div>



<a name="194719332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194719332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194719332">(Apr 20 2020 at 19:06)</a>:</h4>
<p>well, you might note it doesn't resolve <code>contains</code>, so it didn't infer the type at that point either</p>



<a name="194719437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194719437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194719437">(Apr 20 2020 at 19:07)</a>:</h4>
<p>if we emitted diagnostics for this, we would as well at that point</p>



<a name="194719596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194719596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194719596">(Apr 20 2020 at 19:08)</a>:</h4>
<p>both RA and rustc continue afterwards and find out the type, but by then it's too late</p>



<a name="194719748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194719748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194719748">(Apr 20 2020 at 19:10)</a>:</h4>
<p>you might actually be able to see that by doing something like <code>let () = is_derive_registrar_symbol;</code> later, though rustc might be too smart about emitting type errors when there were errors further up, not sure</p>



<a name="194719850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194719850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194719850">(Apr 20 2020 at 19:10)</a>:</h4>
<p>we could totally offer a quick fix for this though <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="194719880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fun%20bug/near/194719880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fun.20bug.html#194719880">(Apr 20 2020 at 19:11)</a>:</h4>
<p>in fact the assist for it already exists, doesn't it</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>